package com.fzz.learnitservice.pojo.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum UserStatusEnum implements BaseEnum {
    DISABLED(0, "已禁用"),
    NORMAL(1, "正常"),
    DELETED(2, "已删除");

    @EnumValue
    private final int code;
    private final String desc;

    public static UserStatusEnum fromCode(Integer code) {
        if(code == null) return NORMAL;
        for (UserStatusEnum e : values()) {
            if (e.getCode() == code) return e;
        }
        return NORMAL; // 默认正常
    }
}

